package linguistic;

import sets.IFuzzySet;
import universe.IUniverseOfDiscourse;

public class Quantifier {
	public enum QuantifierType {
		RELATIVE, ABSOLUTE
	}
	
	private String name;
	private IFuzzySet set;
	private QuantifierType type;
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	/**
	 * Set fuzzy set to quantifier and automatically detect is it a relative or absolute quantifier.
	 * @param set
	 */
	public void setSet(IFuzzySet set) {
		this.set = set;
		
		IUniverseOfDiscourse universe = set.getUniverseOfDiscorse();
		if (universe.getMinBoundary() == 0.0 && universe.getMaxBoundary() == 1.0) {
			type = QuantifierType.RELATIVE;
		} else {
			type = QuantifierType.ABSOLUTE;
		}
	}
	
	public IFuzzySet getFuzzySet() {
		return set;
	}
	
	public void setType(QuantifierType type) {
		this.type = type;
	}
	
	public QuantifierType getType() {
		return type;
	}
	
	public double membershipValue(double value) {
		return set.getMembershipFunction().y(value);
	}
}
